﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Collection.Entities;
using System.Collections.Specialized;
using System.Configuration;
namespace Collection.Core
{
	public static class ClassExtension
	{
		/// <summary>
		/// 将淘宝的数据对象转换为采集服务本地商品对象
		/// </summary>
		/// <param name="_this">淘宝商品对象</param>
		/// <param name="itemDetail">淘宝对象的详细信息</param>
		/// <returns></returns>
		public static Merchandise ToMerchandise(this	Top.Api.Domain.TaobaokeItem _this, Top.Api.Domain.TaobaokeItemDetail itemDetail)
		{
			return	new Merchandise()
			{
				CatalogId = itemDetail.Item.Cid,
				Title = _this.Title,
				Id = itemDetail.Item.NumIid,
				DelistTime = DateTime.Parse(itemDetail.Item.DelistTime),
				CommissionVolume = Decimal.Parse(_this.CommissionVolume),
				CommissionRate = Decimal.Parse(_this.CommissionRate),
				CommissionCount = Int64.Parse(_this.CommissionNum),
				Commission = Decimal.Parse(_this.Commission),
				ClickUrl = _this.ClickUrl,
				Volume = (Int32)_this.Volume,
				ShopClickUrl = _this.ShopClickUrl,
				ItemLocation = _this.ItemLocation,
				ListTime = DateTime.Parse(itemDetail.Item.ListTime),
				Modified = DateTime.Parse(itemDetail.Item.Modified),
				Nick = _this.Nick,
				Picture = _this.PicUrl,
				Price = Decimal.Parse(_this.Price),
				ProductId = itemDetail.Item.ProductId,
				Properties = itemDetail.Item.Props,
				SellerCreditScore = (Int32)_this.SellerCreditScore
			};
		}
	}
}
